import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 86138
 * Date: 2024-07-03
 * Time: 17:11
 */
public class Seven {
    //编写程序数一下 1到 100 的所有整数中出现多少个数字9
    public static void main1(String[] args) {
        int i = 0;
        int count = 0;
        for (i=1;i<=100;i++){
            if(i%10==9){
                count++;
            } else if(i/10==9){
                count++;
            }
        }
        System.out.println("个数为" + count);
    }



    //给定一个数字，判定一个数字是否是素数
    public static boolean isPrime(int num){
        int i = 0;
        if(num<=1){
            return false;
        }
        for(i=2;i<num;i++){
            if(num%i == 0){
                return false;
            }
        }
        return true;
    }

    public static void main2(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int num = scanner.nextInt();
        if(isPrime(num) == false){
            System.out.println("不是素数");
        }else if(isPrime(num) == true){
            System.out.println("是素数");
        }
    }




    public static void main3(String[] args) {
        int i = 0;
        int j = 0;
        Scanner scanner = new Scanner(System.in);
        while(scanner.hasNextInt()){
            int num = scanner.nextInt();
            for(i=0;i<num;i++){
                for(j=0;j<num;j++){
                    if((i+j)==num-1||i==j){
                        System.out.print("*");
                    }else{
                        System.out.print(" ");
                    }
                }
                System.out.println();
            }
        }
    }




    //求出0～n之间的所有“水仙花数”并输出。(“水仙花数”是指一个三位数，其各位数字的立方和确好等于该数本 身，如；153＝1^3＋5^3＋3^3，则153是一个“水仙花数“。
    public static void main4(String[] args) {

        for(int i = 100;i < 999; i++){
            int count = 0;
            int t = i;
            while(t!=0){
                count ++;
                t /= 10;
            }
            t = i;
            int sum = 0;
            while(t!=0){
                sum += Math.pow(t%10,count);
                t /=10;
            }
            if(sum == i){
                System.out.println(i);
            }
        }
    }


    //计算1/1-1/2+1/3-1/4+1/5 …… + 1/99 - 1/100 的值
    public static void main5(String[] args) {
        double flag = 1;
        double sum = 0;
        int i = 0;
        for(i=1;i<=100;i++){
            sum += 1.0/i*flag;
            flag = -flag;
        }
        System.out.println(sum);
    }

    public static void main6(String[] args) {
        double sum = 0;
        for (int i = 1; i <= 100; i++) {
            if (i % 2 == 1) {
                sum += 1.0 / i;
            } else {
                sum -= 1.0 / i;
            }
        }
        System.out.println("表达式的值为: " + sum);
    }


    public static void main7(String[] args) {
        double x=2.0; int y=4; x/=++y;
        System.out.println(x);
    }

    //给定两个数，求这两个数的最大公约数
    //例如：
    //输入：20 40
    //输出：20

    public static int Result(int a,int b){
        while(b!=0){
            int t = b;
            b = a % b;
            a = t;
        }
        return a;
    }

    public static void main8(String[] args) {
        int num1 = 20;
        int num2 = 40;
        int ret = Result(num1,num2);
        System.out.println(ret);
    }


    //求一个整数，在内存当中存储时，二进制1的个数。
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int num = sc.nextInt();

        int count = 0;
        while(num!=0){
            num = num & (num-1);
            count++;
        }
        System.out.println(count);
    }
}
